#{extends 'main.html' /}
#{set title:'帖子管理' /}


<div class="row">
    <div class="col-md-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">帖子</h3>

                <div class="box-tools">
                    <ul class="pagination pagination-sm no-margin pull-right">
                        <li><a href="@{Forum.index(0,9)}">已删除</a></li>
                        <li><a href="@{Forum.index(0,0)}">正常</a></li>
                        <li><a href="@{Forum.index(0,-1)}">全部</a></li>
                    </ul>
                </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body no-padding">

                <table class="table">
                    <tr>
                        <td>标题</td>
                        <td>分类</td>
                        <td>创建于</td>
                        <td>投票数</td>
                        <td>关注数</td>
                        <td>状态</td>
                        <td>操作</td>
                    </tr>
                    #{list posts, as:"post"}
                    <tr>
                        <td><a href="@{Forum.view_post(post.id)}">${post.subject?post.subject:"无标题"}</a></td>
                        <td>分类：${post.board?post.board.name:"无"}</td>
                        <td>${post.created_at.format('yyyy-MM-dd')}</td>
                        <td>${post.voteup_cnt}</td>
                        <td>${post.follow_cnt}</td>
                        <td>${post.state}</td>
                        <td><a href="@{Forum.edit_post(post.id)}">编辑</a></td>
                    </tr>
                    #{/list}
                </table>
            </div>
            <div class="box-footer clearfix">
                <ul class="pagination pagination-sm no-margin pull-right">
                    <li><a href="@{Forum.index(0,state)}">&laquo;</a></li>
                    %{int page_count = Math.ceil(total / 10);
                    for(int i=0;i < page_count; i++){ }%
                    <li><a href="@{Forum.index(i*10,state)}">${i+1}</a></li>
                    %{}}%
                    <li><a href="@{Forum.index((page_count-1)*10, state)}">&raquo;</a></li>
                </ul>
            </div>
        </div>
    </div>
